home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 07 DecisionMaking Architectures / 01 Isla, Blumberg / Mission.java < prev    next >
Encoding:
Java Source  |  2001-09-25  |  1.7 KB  |  82 lines

  1. package bb;
  2.  
  3. import java.util.*;
  4.  
  5. /*
  6. The base class for all missions.
  7.  
  8. @author naimad
  9. */
  10.  
  11. public class Mission {
  12.  
  13.     int number;
  14.     String skillName;
  15.     double priority;
  16.     
  17.     public Mission(String skillname, int number, double priority) {
  18.         this.skillName = skillname;
  19.         this.number = number;
  20.         this.priority = priority;
  21.     }
  22.     
  23.     String getSkillName() {
  24.         return skillName;
  25.     }
  26.     
  27.     int getNumber() {
  28.         return number;
  29.     }
  30.     
  31.     void setNumber(int num) {
  32.         number = num;
  33.     }
  34.     
  35.     boolean isFull() {
  36.         return (members.size() >= number);
  37.     }
  38.  
  39.     public void setPriority(double p) {
  40.         priority = p;
  41.     }
  42.  
  43.     public double getPriority() {
  44.         return priority;
  45.     }
  46.     
  47.     boolean complete = false;
  48.     
  49.     public boolean getMissionComplete() {
  50.         return complete;
  51.     }
  52.     
  53.     public void setMissionComplete() {
  54.         complete = true;
  55.     }
  56.     
  57.     public String toString() {
  58.         if (complete) return skillName + "(C)";
  59.         else return skillName + "(I)";
  60.     }
  61.  
  62.     //Though not strictly necessary, for convenience we also maintain a list
  63.     //of the agents that are officially working on this mission.
  64.     
  65.     Vector members = new Vector();
  66.     public void addMember(Agent a) {
  67.         if (!members.contains(a)) members.addElement(a);
  68.     }
  69.     
  70.     public void removeMember(Agent a) {
  71.         if (members.contains(a)) members.remove(a);
  72.     }
  73.  
  74.     //----------------------------APPLICATION LIST--------------------------
  75.     //A convenience structure to help the blackboard to arbitrate the mission
  76.     //assignments.
  77.     
  78.     public Blackboard.Application applications = null;
  79.  
  80.  
  81. }
  82.